#include<stdio.h>
#include<string.h>

void file_read()
{
    int c;
    int length = 0;
    FILE * fp = fopen("222.txt" , "r");//打开文件

    if (NULL ==fp)
    {
        printf("打开失败!\n");
        return ;
    }
    for (size_t i = 0; EOF != (c = fgetc(fp)); i++)
    {
        if (c == '\n')
        {
            length++;
        }
             
    }
    printf("这个文件的行数为:%d\n" , length);

    fclose(fp);
}

int main(int argc, char *argv[])
{
    file_read();
    return 0;
}
